<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/qs/6.13.0/qs.js"></script>
</head>

<body>
  <script>
    var person = {
      username:'terry张三',
      password:123321,
      telephone:15536332869
    }
    // 1.创建一个实例对象
    var xhr = new XMLHttpRequest();
    // 2.打开一个连接
    xhr.open('post', 'http://121.199.0.35:8888/baseUser/saveOrUpdate');
    // 3.发送请求 表单格式
    // 3.1设置请求头格式为表单格式 
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send(Qs.stringify(person));
    // 4.监听响应
    xhr.onreadystatechange = function () {
      if (xhr.readyState === 4 && xhr.status === 200){
        console.log(JSON.parse(xhr.response))
      }
    }
  </script>
</body>

</html>